package cn.boltzjf.sql4j.ext.postgres;

import java.sql.SQLException;

import org.postgresql.util.PGobject;

import cn.boltzjf.sql4j.dao.ConvertingException;
import cn.boltzjf.sql4j.dao.ValueConverter;

public class PgTypeUtils {
    
    public static final ValueConverter VALUE_CONVERTER = new ValueConverter();

    public static PGobject jsonb(String value) {
        PGobject obj = new PGobject();
        obj.setType(("jsonb"));
        try {
            obj.setValue(value);
        } catch (SQLException e) {
            throw new ConvertingException(String.format("Failed to convert String %s to JSONB: %s", value, e.getMessage()), e);
        }
        return obj;
    }

}
